
import mapper.checkitemMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;
import pojo.CheckItem;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Scanner;

public class test {
    public static void main(String[] args) throws IOException {
        String resource = "mybatisConfiguration.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
//        List<CheckItem> objects = sqlSession.selectList("checkItem.selectAll");
//        System.out.println(objects);

//        通过mapper代理的方式，通过调用接口方法的方式
        checkitemMapper mapper = sqlSession.getMapper(checkitemMapper.class);
        List<CheckItem> checkItems = mapper.selectAll();
        System.out.println(checkItems);


    }
    @Test
    public void zongce(){
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入循环次数：");
        int loopCount = scanner.nextInt();

        int sum = 0;
        for (int i = 0; i < loopCount; i++) {
            System.out.print("请输入第" + (i + 1) + "次循环的第一个整数：");
            int num1 = scanner.nextInt();

            System.out.print("请输入第" + (i + 1) + "次循环的第二个整数：");
            int num2 = scanner.nextInt();

            int multiplyResult = num1 * num2;

            sum += multiplyResult;
        }

        System.out.println("所有循环的相乘结果累加的总和为：" + sum);

    }
}
